package org.uniview.common.service.schedule;

import java.sql.Timestamp;

/**
 * This job is designed to run only once in schedule service.
 * 
 * @author James Gao 2007.02.02.
 * @version v1.0
 */
public abstract class RunOnceJob extends SimpleJob {
	/**
	 * I only run once, so this value can be set to 0.
	 */
	private static final long INTERVAL = 24L * 60 * 60 * 1000;

	/**
	 * I only run once, so this value is sure to be 1.
	 */
	private static final int REPEAT_COUNT = 1;

	/**
	 * Job name.
	 */
	private String jobName;

	/**
	 * Job group name.
	 */
	private String jobGroup;

	public RunOnceJob(String jobName, String jobGroup) {
		this.jobName = jobName;
		this.jobGroup = jobGroup;
	}

	/**
	 * 
	 * @return
	 */
	public long getInterval() {
		return INTERVAL;
	}

	/**
	 * 
	 * @return
	 */
	public int getRepeatCount() {
		return REPEAT_COUNT;
	}

	/* (non-Javadoc)
	 * @see com.gwf.uniview.common.service.schedule.IJob#getEndTime()
	 */
	public Timestamp getEndTime() {
		// I return null. Cron will execute continuously if end time is null. But i've set repeat count to 1. 
		return null;
	}

	/* (non-Javadoc)
	 * @see com.gwf.uniview.common.service.schedule.IJob#getJobGroup()
	 */
	public String getJobGroup() {
		return this.jobGroup;
	}

	/* (non-Javadoc)
	 * @see com.gwf.uniview.common.service.schedule.IJob#getJobName()
	 */
	public String getJobName() {
		return this.jobName;
	}
}